import { DynamicProps } from '#/utils';
import { ActionItem, BasicTableProps, FormProps } from '@/components/Table';
import { ExcelConfigType } from '@/utils/props';

interface ICommonMetaData {
  mode?: 'model' | 'drawer' | 'page';
  pkid?: string;
  pkidAlias?: string;
}
export interface IMultipleForm {
  forms: Array<Partial<DynamicProps<FormProps>>>;
}
export interface IMetaListData extends ICommonMetaData {
  tableProps: Partial<DynamicProps<BasicTableProps>>;
  excelConfig?: ExcelConfigType;
  editActionItem?: ActionItem | ((record?: any) => ActionItem);
  delActionItem?: ActionItem | ((record?: any) => ActionItem);
  actionItems?: (data?: object, record?: any) => Array<ActionItem>;
  delFN?: PromiseFn;
  queryParams?: {
    delParam?: Array<string> | PromiseFn<object, any>;
    editParam?: Array<string>;
  };
  pageMethod?: {
    addFn?: Fn;
    editFn?: Fn;
  };
  auth?: string;
}
export interface IMetaHandleData extends ICommonMetaData {
  formProps: Partial<DynamicProps<FormProps>>;
  title: string;
  customTitle?: string;
  details?: PromiseFn;
  queryResult?: PromiseFn;
  saveOrUpdate?: PromiseFn;
  beforeSubmit?: PromiseFn;
  beforeQuery?: PromiseFn;
  afterQuery?: PromiseFn;
  commonQuery?: PromiseFn;
  saveFn?: PromiseFn;
  updateFn?: PromiseFn;
  queryParams?: Array<string>;
  customDetails?: (data?: any) => void;
  debug?: boolean;
}

export interface IMetaHandlePageData extends Omit<IMetaHandleData, 'details'> {
  details?: PromiseFn;
  finishJumpFn?: PromiseFn;
}
export interface IMetaMultipleFormhandlePageData extends Omit<IMetaHandlePageData, 'formProps'> {
  forms: Array<Partial<DynamicProps<FormProps>>>;
}
